home *** CD-ROM | disk | FTP | other *** search
/ Resource Library: Multimedia / Resource Library: Multimedia.iso / maestro / source / timeline / notesinf.c < prev    next >
Encoding:
Text File  |  1993-06-15  |  26.5 KB  |  528 lines

  1. /*
  2.  * Copyright (c) 1990, 1991 Stanford University
  3.  *
  4.  * Permission to use, copy, modify, and distribute this software and 
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that (i) the above copyright notices and this permission notice appear in
  7.  * all copies of the software and related documentation, and (ii) the name
  8.  * Stanford may not be used in any advertising or publicity relating to
  9.  * the software without the specific, prior written permission of
  10.  * Stanford.
  11.  * 
  12.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
  13.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
  14.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
  15.  *
  16.  * IN NO EVENT SHALL STANFORD BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  17.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES
  18.  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT
  19.  * ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY,
  20.  * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21.  * SOFTWARE.
  22.  */
  23.  
  24. /* $Header: /Source/Media/collab/TimeLine/RCS/notesInfo.c,v 1.0 91/09/30 17:01:34 chua Exp Locker: drapeau $ */
  25. /* $Log:    notesInfo.c,v $
  26.  * Revision 1.0  91/09/30  17:01:34  chua
  27.  * Update to version 1.0
  28.  * 
  29.  * Revision 0.72  91/09/25  14:04:30  chua
  30.  * Changed InitInstInfoWindow to InitEditInfoWindow.
  31.  * 
  32.  * Revision 0.71  91/09/25  13:51:12  chua
  33.  * Changed the instrument field, instInfo, to editInfo.
  34.  * Changed InstrumentInfo to EditInfo.
  35.  * 
  36.  * Revision 0.70  91/09/23  17:13:26  chua
  37.  * Change tlFrame->selectedInstrument to tlFrame->noteInstrument as the
  38.  * latter is now used to indicate which instrument has the currently
  39.  * selected note.
  40.  * 
  41.  * Revision 0.69  91/09/19  17:28:59  chua
  42.  * Make sure that variables are initialized properly.  Change formatting slightly,
  43.  * so that (if, for, while) statements with only one statement in them will not have
  44.  * braces.
  45.  * 
  46.  * Revision 0.68  91/08/05  16:53:24  chua
  47.  * Deleted the RepaintCanvas routine, as it is no longer necessary.  In places where it
  48.  * is called, just call the ScrollToFirstQuarter routine, which will do the necessary
  49.  * repaint as well.
  50.  * 
  51.  * Revision 0.67  91/08/05  13:04:32  chua
  52.  * Changed the name of the function call, ScrollToMiddle to ScrollToFirstQuarter.
  53.  * 
  54.  * Revision 0.66  91/07/26  17:26:47  chua
  55.  * In SelectNoteInfo, update the fields in the region info popup window so that 
  56.  * the start and end positions of a selected region are zero.
  57.  * 
  58.  * Revision 0.65  91/07/22  15:21:20  chua
  59.  * In the NotesInfoListNotify procedure, where we check to see if scrolling is necessary, the
  60.  * code is replaced by a call to ScrollToMiddle instead.
  61.  * 
  62.  * Revision 0.64  91/07/17  16:33:16  chua
  63.  * Modified some of the comments to the NotesInfoListNotify function.
  64.  * 
  65.  * Revision 0.62  91/07/17  10:30:06  chua
  66.  * In the NotesInfoListNotify procedure (at line 512), when clearing the selected
  67.  * area (line 512), take into the account the canvasStart position when specifying
  68.  * the x coordinate.
  69.  * 
  70.  * Revision 0.61  91/07/09  18:25:02  chua
  71.  * Made changes to the startX, endX variables so that they now store the position at the
  72.  * largest zoom level (zoom level = 1).   Thus, the appropriate multiplication or
  73.  * division by the zoom level has to be made when these variables are used.  This will
  74.  * include lastX (position of the playback head) as well.
  75.  * 
  76.  * Revision 0.60  91/07/09  17:01:23  chua
  77.  * In SelectNoteInfo, when setting the selected region, set the note selected
  78.  * region (startnoteX, etc) to the note boundary as well.
  79.  * 
  80.  * Revision 0.59  91/06/25  17:45:48  chua
  81.  * Added a new field, LabelText to the instrument info popup window.
  82.  * Replaced all occurrences of the constant HalfSecondScale with the value 5 as the constant is not in
  83.  * use anymore.
  84.  * 
  85.  * Revision 0.58  91/06/05  16:22:58  chua
  86.  * In the InitNotesInfo routine, add code to hide a panel list when updating and reshow the
  87.  * list again once updating is doen.
  88.  * 
  89.  * Revision 0.57  91/06/04  17:37:23  chua
  90.  * Added the copyright comments in the beginning of the file.
  91.  * 
  92.  * Revision 0.56  91/06/04  17:29:53  chua
  93.  * In the InitInstInfoWindow routine, add code to initialize the message field indicating
  94.  * which TimeLine document the pop-up window belongs to.
  95.  * 
  96.  * Revision 0.55  91/06/03  11:12:00  chua
  97.  * Make changes to accomodate multiple documents.  This involves identifying
  98.  * which is the current active window, that is, the one where the last mouse
  99.  * click was done.
  100.  * 
  101.  * Revision 0.54  91/05/30  12:07:59  chua
  102.  * In ShowInfoWindow, make a call to InitNotesInfo to update the panel list.
  103.  * 
  104.  * In InitNotesInfo, an extra parameter is added (deselect).  This parameter is 
  105.  * usually 1, except when called from ShowInfoWindow, when it has the value 0.
  106.  * It tells the function whether the currently selected note is to be deselected.
  107.  * Also, a check is made in the function to see if the pop-up window is currently
  108.  * showing.  If not, the updating of the panel list is not done.  This is to
  109.  * avoid the delays in updating the panel list.
  110.  * 
  111.  * Revision 0.53  91/05/29  18:31:13  chua
  112.  * In the InitInstInfoWindow, delete the if-statement testing if instrument->instInfo == NULL, as
  113.  * it is not necessary.
  114.  * 
  115.  * In the InitNotesInfo procedure, a minor change is made to the last part of the function, when
  116.  * extra old entries are deleted.  
  117.  * 
  118.  * Revision 0.52  91/05/29  14:41:15  chua
  119.  * Delete the ClearNoteInfoList and UpdateNotesCount procedures, which are made unnecessary by the
  120.  * rewriting of the InitNotesInfo procedure.  This rewriting is an attempt to avoid the random
  121.  * segmentation faults caused by the previous way of updating the info window panel lists.
  122.  * Please refer to the function heading commnets of the InitNotesInfo procedure for more
  123.  * information.
  124.  * 
  125.  * Revision 0.51  91/05/28  12:13:54  chua
  126.  * Change in the DESELECT option in NotesInfoListNotify procedure.  Do not set selectedInstrument = NULL
  127.  * then, as that might cause a segmentation fault since selectedInstrument may be accessed later on.
  128.  * 
  129.  * Revision 0.50  91/05/24  16:37:18  chua
  130.  * *** empty log message ***
  131.  * 
  132.  * Revision 0.49  91/05/23  17:31:37  chua
  133.  * In the ClearNotesInfoList routine,  call DeselectNote first to deselect any selected note before
  134.  * deleting the whole list.
  135.  * 
  136.  * Revision 0.48  91/05/22  16:40:27  chua
  137.  * In the SelectNotesInfo function, add the code that was in the CheckIfNoteSelected function
  138.  * previously in edit.c  The code has the effect of setting the selected region coordinates
  139.  * to the selected note.
  140.  * 
  141.  * Revision 0.47  91/05/22  13:56:31  chua
  142.  * In SelectNoteInfo, set noteSelected to 1.
  143.  * In DeselectNote, check if noteSelected = 1 before performing any of the procedures.  At the`
  144.  * end of the procedures, set noteSelected = 0.
  145.  * 
  146.  * Revision 0.46  91/05/22  11:43:42  chua
  147.  * In the InitNotesInfo and ClearNoteInfoList info, instead of making use of an attribute list
  148.  * to perform updates, we now just use one xv_set call for each item to be updated, which 
  149.  * results in quite a number of xv_set calls.  The reason the attribute list method is not 
  150.  * used is because only 250 attributes can be passed in a xv_set call at one time, which would
  151.  * limit the number of notes that can be added.  Also, when allocating space for the avlist,
  152.  * it seems it requires more than what has been calculated, or else the program crashes at
  153.  * some stage (not always well defined).
  154.  * 
  155.  * Revision 0.45  91/05/17  16:57:05  chua
  156.  * *** empty log message ***
  157.  * 
  158.  * Revision 0.44  91/05/15  14:54:23  chua
  159.  * Added a new function DeselectNote() which will deselect the previously selected note on both the notes
  160.  * info panel list as well as on the timeline canvas display.
  161.  * 
  162.  * In the PANEL_LIST_OP_SELECT switch statement in the NoteInfoListNotify function, the section of code
  163.  * deselecting the previously selected note is replaced by the above function call.
  164.  * 
  165.  * Revision 0.43  91/05/15  14:15:25  chua
  166.  * Changes in the NotesInfoListNotify function:
  167.  * 
  168.  * In the PANEL_LIST_OP_DESELECT switch statement,  if the current instrument is the same as the previously
  169.  * selected instrument, the selectedInstrument pointer is set to NULL, since we are deselecting a note.
  170.  * 
  171.  * In the PANEL_LIST_OP_SELECT swithc statement, if the previously selected instrument (as pointed to
  172.  * by the selectedInstrument pointer) is different from the currently selected instrument, we deselect the
  173.  * previously selected note in the instrument pointed to by selectedInstrument.  The selectedInstrument
  174.  * pointer is then set to the currently chosen instrument.
  175.  * 
  176.  * 
  177.  * Revision 0.42  1991/04/24  01:04:21  chua
  178.  * A new function, ShowInfoWindow is created, which when called, will bring the instrument pop-up
  179.  * window to the front.
  180.  *
  181.  * The function InitInstInfoWindow is now called each time an instrument is created.  The last
  182.  * two lines (showing the window) are deleted and put in the ShowInfoWindow function.
  183.  *
  184.  * In the InitNotesInfo and ClearNoteInfoList procedures, a check is made to see if there are
  185.  * any notes in the note list, since an error occurs if we try to do an xv_set on
  186.  * the ATTR_LIST with no strings.  For example, we have PANEL_LIST_STRINGS, which is expected to
  187.  * be followed by at least one string.  But if there are no notes, no string follows and an error
  188.  * results.
  189.  *
  190.  * Revision 0.41  1991/04/08  22:00:26  chua
  191.  * Correcting a change in the notesinforcsid line.
  192.  *
  193.  * Revision 0.40  1991/04/08  21:49:11  chua
  194.  * This file contains functions to maintain the instrument info pop-up window.  Brief descriptions of the
  195.  * functions in this file follows.
  196.  *
  197.  * InitInstInfoWindow - Creates the pop-up window for an instrument if necessary and moves it to the foreground.
  198.  *              (make it visible).
  199.  * UpdateNotesCount - Update the notes count message in the info pop-up window.
  200.  * InitNotesInfo - Updates the panel list in the info pop-up window with the notes information from the
  201.  *            instrument's notes list.
  202.  * FindNote - Returns a pointer to a note given its relative position in the notes list.
  203.  * ClearNoteInfoList - Clears the panel list of its entries and also deselect any currently selected note.
  204.  * SelectNoteInfo - Updates the info display fields in the pop-up window with values of the selected note,
  205.  *             and draw the selected note in the 'Sunken' mode.
  206.  * DeselectNoteInfo - Draw the deselected note back in the 'Raised' mode and clear all the info display fields.
  207.  * NotesInfoListNotify - Called when the user selects or deselects an entry in the panel list in a info pop-up
  208.  *              window.  First, determine which instrument this pop-up window belongs to by checking
  209.  *              the PANEL_CLIENT_DATA value.  Then perform the appropriate selecting or deselecting
  210.  *              procedures.
  211.  * */
  212.  
  213. static char notesinforcsid[] = "$Header: /Source/Media/collab/TimeLine/RCS/notesInfo.c,v 1.0 91/09/30 17:01:34 chua Exp Locker: drapeau $";
  214.  
  215. #include "main.h"
  216. #include "EditInfo_ui.h"
  217.  
  218. Xv_font *font;                                /* Font used in the note info panel list */
  219.  
  220. /*
  221.  * This function takes an instrument node pointer as an argument and creates a instrument info pop-up window for that instrument.
  222.  * First, a check is made to see if a pop-up window has already been created for that window.
  223.  * The objects initialize procedure is called to create the pop-up window if it does not already exist.  The first parameter in the call is the pointer
  224.  * to the pop-up window.  This is checked to see if it is NULL, or if it already exist.  If it is the latter, then no new creation of a pop-up window
  225.  * is done.  The second parameter is the owner of the pop-up window, which in this case is the parent frame (the TimeLine Editor window).
  226.  * The first parameter is actually redundant in this case (we could have just set it to NULL), since we already checked if the pop-up window exists
  227.  * earlier.
  228.  * Set the instrument's relative position in the instrument list to be the value in the panel's PANEL_CLIENT_DATA.  This is necessary so that we can
  229.  * differentiate between the various pop-up windows since they all call the same notify procedure.
  230.  * Next, the application name and the hostname is set on the pop-up window textfields.
  231.  * The pop-up window is made visible by pushing in the push-pin and setting XV_SHOW for that window to be TRUE.
  232.  * Called by ShowNotesInfoHandler (openApps.c)
  233.  */
  234. void InitEditInfoWindow(instrument, tlFrame)
  235.      Instrument *instrument;
  236.      TimeLineFramePtr tlFrame;
  237. {
  238.   int whichFrame;
  239.   char buf[40];
  240.   
  241.   whichFrame = xv_get(tlFrame->TimeLine_window->controls, PANEL_CLIENT_DATA);
  242.   instrument->editInfo = EditInfo_EditInfoWindow_objects_initialize (instrument->editInfo, tlFrame->TimeLine_window->window);
  243.   font = (Xv_font *) xv_find(instrument->editInfo->EditInfoWindow,  /* Set the font for the note info panel list */
  244.                  FONT,
  245.                  FONT_FAMILY, FONT_FAMILY_LUCIDA_FIXEDWIDTH,
  246.                  FONT_STYLE, FONT_STYLE_NORMAL,
  247.                  FONT_SIZE, 12,
  248.                  NULL);
  249.   if (whichFrame == 0) 
  250.     sprintf(buf, "Clipboard");
  251.   else 
  252.     sprintf (buf, "Document %d\n", whichFrame);
  253.   xv_set(instrument->editInfo->TimeLineDocMsg,                /* To indicate which TimeLine document the popup window belongs to */
  254.      PANEL_LABEL_STRING, buf, NULL);
  255.   xv_set(instrument->editInfo->NoteInfoList,                /* Attach the instrument's relative position as the PANEL_CLIENT_DATA. */
  256.      PANEL_CLIENT_DATA, instrument->relativePosition,        /* Lets the program know which instrument the panel belongs to. */
  257.      NULL);
  258.   xv_set(instrument->editInfo->AppNameText,                /* Set the application name on the pop-up window */
  259.      PANEL_LABEL_STRING, instrument->port->appName, NULL);
  260.   xv_set(instrument->editInfo->HostnameText,                /* Set the hostname on the pop-up window */
  261.      PANEL_LABEL_STRING, instrument->port->hostName, NULL);
  262.   xv_set(instrument->editInfo->MiddlePanel, XV_FONT, font, NULL);  /* Set the font for the panel list */
  263.   InitNotesInfo(instrument, 1, tlFrame);                        /* Initialize the notes count and notes info */
  264.   xv_set(instrument->editInfo->EditInfoWindow, XV_SHOW, FALSE, NULL); /* Do not show the pop-up window until the user request it */
  265. }
  266.  
  267. /* 
  268.  * This function will pop up the info window and bring it to the front.
  269.  * It will also call the InitNotesInfo window to update the information on the info pop-up window.
  270.  */
  271. void ShowInfoWindow(instrument, tlFrame)
  272.      Instrument *instrument;
  273.      TimeLineFramePtr tlFrame;
  274. {
  275.   xv_set(instrument->editInfo->EditInfoWindow,            /* Make the pop-up window visibile */
  276.      FRAME_CMD_PUSHPIN_IN, TRUE, NULL);
  277.   xv_set(instrument->editInfo->EditInfoWindow, XV_SHOW, TRUE, NULL);
  278.   InitNotesInfo(instrument, 0, tlFrame);
  279. }
  280.  
  281. /*
  282.  * This function will go through an instrument's note list and create the information on the info window panel list which contains information for
  283.  * all the notes found in the instrument.
  284.  * Note that the function will be performed only if the pop-up window is showing.  This is to avoid the delay when inserting or deleting notes due
  285.  * to the updating of the panel list.  Thus, when the pop-up window is not showing, the panel list will not be updated.
  286.  * The parameter deselect indicates if the selected note is to be deselected.  This is desired in most cases except when the info window is brought
  287.  * forward from a closed position.  (when the function is called by ShowInfoWindow).
  288.  * First, check to see if deselecting a selected note needs to be done.  This is done if the instrument is the same as the selected instrument and
  289.  * the deselect parameter = 1.
  290.  * Update the display for the number of notes in the info pop-up window.
  291.  * Next, find out the current number of lines in the panel list.
  292.  * Go through the panel list and update it with the new information.  Any old strings are replaced by new ones.  If the number of old strings exceed
  293.  * the number of new strings, the excess old strings are deleted.  Conversely, if the number of new strings exceed the number of old strings, the
  294.  * extra new strings will be inserted.
  295.  * Lastly, highlight the selected note (if any) in the panel list.
  296.  * Called by InitEditInfoWindow (notesInfo.c), Load (file.c), DeleteNote and AddandDisplayNewNote (note.c), ShowInfoWindow(notesInfo.c)
  297.  */
  298. void InitNotesInfo(instrument, deselect, tlFrame)
  299.      Instrument *instrument;
  300.      int deselect;
  301.      TimeLineFramePtr tlFrame;
  302. {
  303.   Note     *currentNote;
  304.   char     buf[100], numnotes[5];
  305.   int     count = 0, i;
  306.   int     oldlines, replace;
  307.  
  308.   if (instrument == tlFrame->noteInstrument && deselect)
  309.     DeselectNote(tlFrame);
  310.   if (xv_get(instrument->editInfo->EditInfoWindow, XV_SHOW) == TRUE) 
  311.   {  
  312.     sprintf(numnotes, "%d", instrument->numnotes);            /* Update the display for the number of notes */
  313.     xv_set(instrument->editInfo->NotesCountMessage,
  314.        PANEL_LABEL_STRING, numnotes, NULL);
  315.     oldlines = xv_get(instrument->editInfo->NoteInfoList,        /* Get the number of rows currently in the panel list */
  316.               PANEL_LIST_NROWS);
  317.     replace = oldlines;
  318.     if (instrument->numnotes <= oldlines) 
  319.       replace = instrument->numnotes;
  320.     currentNote = instrument->firstNote;
  321.     xv_set(instrument->editInfo->NoteInfoList,                /* Hide the panel list while updating is done */
  322.        XV_SHOW, FALSE, NULL);
  323.     for (i=0; i < replace; i++)                        /* Replace the old strings by the new ones. */
  324.     {
  325.       sprintf(buf, " %4d.    %-25.22s%4d:%02d   %4d:%02d   %4d:%02d",
  326.           count+1, currentNote->ms->selection->label, 
  327.           currentNote->startMin, currentNote->startSec, 
  328.           currentNote->endMin, currentNote->endSec,
  329.           currentNote->durationMin, currentNote->durationSec);
  330.       xv_set (instrument->editInfo->NoteInfoList,
  331.           PANEL_LIST_STRING, i, buf,
  332.           PANEL_LIST_FONT, i, font,
  333.           NULL);
  334.       count++;
  335.       currentNote = currentNote->next;
  336.     }
  337.     if (instrument->numnotes > oldlines) 
  338.     {
  339.       for (i=oldlines; i < instrument->numnotes; i++)            /* Insert the additional new strings */
  340.       {
  341.     sprintf(buf, " %4d.    %-25.22s%4d:%02d   %4d:%02d   %4d:%02d",
  342.         count+1, currentNote->ms->selection->label,
  343.         currentNote->startMin, currentNote->startSec, 
  344.         currentNote->endMin, currentNote->endSec,
  345.         currentNote->durationMin, currentNote->durationSec);
  346.     xv_set (instrument->editInfo->NoteInfoList,
  347.         PANEL_LIST_INSERT, i,
  348.         PANEL_LIST_STRING, i, buf,
  349.         PANEL_LIST_FONT, i, font,
  350.         NULL);
  351.     count++;
  352.     currentNote = currentNote->next;
  353.       }
  354.     }
  355.     else for (i=instrument->numnotes; i < oldlines; i++)        /* Delete the excess old strings */
  356.       xv_set(instrument->editInfo->NoteInfoList,
  357.          PANEL_LIST_DELETE, instrument->numnotes,
  358.          NULL);
  359.     if (tlFrame->noteInstrument != NULL)
  360.       if (tlFrame->noteInstrument->infoNote != NULL)            /* Deselect the note on the panel list */
  361.     xv_set(tlFrame->noteInstrument->editInfo->NoteInfoList,
  362.            PANEL_LIST_SELECT, tlFrame->noteInstrument->selectedInfoNote,
  363.            TRUE, NULL);
  364.     xv_set(instrument->editInfo->NoteInfoList,                /* Show the panel list again */
  365.        XV_SHOW, TRUE, NULL);
  366.   }
  367. }
  368.  
  369. /*
  370.  * Function that will return a pointer to the appropriate note node given its relative position in the notes list of a given instrument node.
  371.  * Called by NotesInfoListNotify (notesInfo.c)
  372.  */
  373. Note *FindNote(instrument, relativePosition)
  374.      Instrument *instrument;
  375.      int     relativePosition;
  376. {
  377.   int         i;
  378.   Note *currentNote;
  379.   
  380.   currentNote = instrument->firstNote;                        /* To find the appropriate instrument node */
  381.   for (i=0; i < relativePosition && currentNote != NULL; i++)
  382.     currentNote = currentNote->next;
  383.   return currentNote;
  384.   
  385. }
  386.   
  387. /* 
  388.  * This function will load in the document name and the selection structure data onto the Instrument Info pop-up window for a given note.
  389.  * It will also update the message field indicating which note was selected.
  390.  * The note is then redrawn so that it appears selected (Sunken).
  391.  * Called by NotesInfoListNotify (notesInfo.c), AddandDisplayNewNote (note.c)
  392.  */
  393. void SelectNoteInfo(instrument, tlFrame)
  394.      Instrument *instrument;
  395.      TimeLineFramePtr tlFrame;
  396. {
  397.   char start[4], end[4], selected[4];
  398.   long templastX;
  399.   
  400.   tlFrame->noteInstrument = instrument;
  401.   sprintf(start, "%d", instrument->infoNote->ms->selection->start); /* Set all the display values in the info pop-up window */
  402.   sprintf(end, "%d", instrument->infoNote->ms->selection->end);
  403.   sprintf(selected, "%d", instrument->selectedInfoNote + 1);
  404.   xv_set (instrument->editInfo->DocNameText, PANEL_VALUE, instrument->infoNote->ms->documentName, NULL);
  405.   xv_set (instrument->editInfo->SelectedNoteValue, PANEL_LABEL_STRING, selected, NULL);
  406.   xv_set (instrument->editInfo->SelectionStartValue, PANEL_LABEL_STRING, start, NULL);
  407.   xv_set (instrument->editInfo->SelectionEndValue, PANEL_LABEL_STRING, end, NULL);
  408.  
  409.   templastX = tlFrame->lastX;                            /* Draw note so that it is sunken (appearing selected) */
  410.   DrawPlaybackHead(-1, tlFrame);
  411.   DrawNote(instrument->infoNote->start, instrument->cableStart - NoteHeight/2,
  412.        instrument->infoNote->ms->duration * 5, Sunken, tlFrame);
  413.   DrawPlaybackHead(templastX, tlFrame);
  414.   tlFrame->startX = tlFrame->startnoteX = tlFrame->noteInstrument->infoNote->start;
  415.   tlFrame->endX = tlFrame->endnoteX = tlFrame->noteInstrument->infoNote->end;
  416.   tlFrame->startY = tlFrame->startnoteY = tlFrame->noteInstrument->relativePosition * (IconHeight + IconGap);
  417.   tlFrame->endY = tlFrame->endnoteY = (tlFrame->noteInstrument->relativePosition + 1) * (IconHeight + IconGap);
  418.   tlFrame->noteSelected = 1;
  419.   tlFrame->areaSelected = 0;
  420.   SetStartEndRegion(tlFrame, 0, 0);
  421. }
  422.  
  423. /* 
  424.  * This function will deselect a selected info note and clear the infoNote pointer and relative position variables in the instrument note 
  425.  * that owns the note. It will redraw the note so that it appears 'Raised'.
  426.  * Called by DeselectNote (notesInfo.c)
  427.  */
  428. void DeselectNoteInfo(instrument, tlFrame)
  429.      Instrument *instrument;
  430.      TimeLineFramePtr tlFrame;
  431. {
  432.   long templastX;
  433.   
  434.   if (instrument->infoNote != NULL)                    /* Redraw a previously selected note so that it now appears Raised again */
  435.   {
  436.     templastX = tlFrame->lastX;
  437.     DrawPlaybackHead(-1, tlFrame);
  438.     DrawNote(instrument->infoNote->start, instrument->cableStart - NoteHeight/2,
  439.          instrument->infoNote->ms->duration * 5, Raised, tlFrame);
  440.     DrawPlaybackHead(templastX, tlFrame);
  441.   }
  442.   instrument->infoNote = NULL;                        /* Reset the pointer to the selected info note */
  443.   instrument->selectedInfoNote = -1;
  444.   xv_set (instrument->editInfo->DocNameText, PANEL_VALUE, "", NULL); /* Clear the info fields as no note is selected */  
  445.   xv_set (instrument->editInfo->SelectedNoteValue, PANEL_LABEL_STRING, "none", NULL);
  446.   xv_set (instrument->editInfo->SelectionStartValue, PANEL_LABEL_STRING, "", NULL);
  447.   xv_set (instrument->editInfo->SelectionEndValue, PANEL_LABEL_STRING, "", NULL);
  448. }
  449.     
  450. /*
  451.  * This function will deselect the currently selected note from both the canvas display and the notes info panel list.  It first deselects the note
  452.  * on the panel list by setting the PANEL_LIST_SELECT attribute to FALSE, and then calls DeselectNoteInfo to deselect the note on the canvas and also
  453.  * update the information on the instrument info pop-up window.
  454.  * Called by NoteInfoListNotify (notesInfo.c), AddandDisplayNewNote (note.c)
  455.  */
  456. void DeselectNote(tlFrame)
  457.      TimeLineFramePtr tlFrame;
  458. {
  459.   if (tlFrame->noteInstrument != NULL)
  460.   {
  461.     if (tlFrame->noteInstrument->infoNote != NULL)            /* Deselect the note on the panel list */
  462.       xv_set(tlFrame->noteInstrument->editInfo->NoteInfoList,
  463.          PANEL_LIST_SELECT, tlFrame->noteInstrument->selectedInfoNote,
  464.          FALSE, NULL);
  465.     DeselectNoteInfo (tlFrame->noteInstrument, tlFrame);        /* Deselect the note on the canvas display */
  466.     tlFrame->noteInstrument = NULL;
  467.     tlFrame->noteSelected = 0;
  468.   }
  469. }
  470.  
  471. /*
  472.  * Notify callback function for `NoteInfoList'.
  473.  * First, get which instrument is called by doing a xv_get on the PANEL_CLIENT_DATA.
  474.  * On a DESELECT operation, the function will call the DeselectNoteInfo function (see above) to deselect a note.
  475.  * If the instrument is the same as the previously selected instrument, the selected instrument pointer is set to NULL since it has been deselected.
  476.  * On a SELECT operation, the function will first check to see if the previously selected instrument is the same one.  If not, it needs to be
  477.  * deselected first.  The function will then scan the panel list entry that is selected to determine which entry has been selected.
  478.  * It will then get the pointer to the appropriate note in the instrument notes list (since it now knows the relative position of the note by its
  479.  * position in the panel list.
  480.  * A check is made to determine if the start of the note currently falls in the canvas window.  If not, the canvas is remapped to the correct portion of
  481.  * the TimeLine so that the selected note will be visible somewhere in the middle of the canvas window.
  482.  * The SelectNoteInfo procedure is then called to perform the necessary selection procedures (see above).
  483.  */
  484. int NotesInfoListNotify(item, string, client_data, op, event)
  485.      Panel_item    item;
  486.      char        *string;
  487.      Xv_opaque    client_data;
  488.      Panel_list_op    op;
  489.      Event        *event;
  490. {
  491.   Instrument     *instrument;
  492.   int         selection;
  493.   TimeLineFramePtr tlFrame;
  494.   EditInfo_EditInfoWindow_objects    *ip = (EditInfo_EditInfoWindow_objects *) xv_get(item, XV_KEY_DATA, INSTANCE);
  495.   Window    owner = xv_get(ip->EditInfoWindow, XV_OWNER);
  496.   TimeLine_window_objects * tlip = (TimeLine_window_objects *) xv_get(owner, XV_KEY_DATA, INSTANCE);
  497.  
  498.   tlFrame = TimeLineWindow[xv_get(tlip->controls, PANEL_CLIENT_DATA)];
  499.   instrument = (Instrument*) FindInstrument((int)xv_get(item, PANEL_CLIENT_DATA), tlFrame); /* Find the instrument for this panel list */
  500.   switch(op) 
  501.   {
  502.    case PANEL_LIST_OP_DESELECT:
  503.     DeselectNote(tlFrame);
  504.     break;
  505.    case PANEL_LIST_OP_SELECT:
  506.     if (tlFrame->noteInstrument != instrument)                /* If the previously selected instrument is a different one, deselect it. */
  507.       DeselectNote(tlFrame);                        /* If it was the same one, it would have already been deselected in the */
  508.                                     /* PANEL_LIST_OP_DESELECT routine */
  509.     tlFrame->noteInstrument = instrument;                /* Set the selected instrument to this newly selected one */
  510.     sscanf(string, "%d", &selection);                    /* Get which note is selected */
  511.     instrument->selectedInfoNote = selection - 1;
  512.     instrument->infoNote = (Note *) FindNote(instrument, instrument->selectedInfoNote);
  513.     ScrollToFirstQuarter(tlFrame, instrument->infsuote->start, 0);
  514.     if (tlFrame->areaSelected)                        /* Clear the previously selected area */
  515.       XFillRectangle(tlFrame->dpyDraw, tlFrame->xidDraw, tlFrame->gcLine, (tlFrame->startX / tlFrame->zoomLevel) - tlFrame->canvasStart,
  516.              tlFrame->startY, (tlFrame->endX - tlFrame->startX) / tlFrame->zoomLevel,
  517.              tlFrame->endY - tlFrame->startY);
  518.     SelectNoteInfo (instrument, tlFrame);
  519.     break;
  520.    case PANEL_LIST_OP_VALIDATE:
  521.     break;
  522.    case PANEL_LIST_OP_DELETE:
  523.     break;
  524.   }
  525.   return XV_OK;
  526. }
  527.  
  528.